#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->groupBox->setCheckable(true);
    ui->tabWidget->setTabsClosable(true);
    ui->tabWidget->setMovable(true);

}


Widget::~Widget()
{
    delete ui;
}


void Widget::on_tabWidget_tabCloseRequested(int index)
{
    ui->tabWidget->removeTab(index);
}



void Widget::on_pushButton_clicked()
{
    int cnt = ui->tabWidget->count();
    QWidget* w = new QWidget();
    ui->tabWidget->addTab(w,QString("tab") + QString::number(cnt + 1));

    QLabel* label = new QLabel(w);
    label->setText("这是标签页" + QString::number(cnt + 1));
    ui->tabWidget->setCurrentIndex(cnt);
}
